//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Policy Injection Application Block
//===============================================================================

using System;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.Design;
using EntLibContrib.PolicyInjection.CallHandlers.Configuration.Design.Properties;

namespace EntLibContrib.PolicyInjection.CallHandlers.Configuration.Design
{
	/// <summary>
	/// Command registrar class that adds the commands for the various call handler nodes.
	/// </summary>
	internal class PolicyInjectionCallHandlersCommandRegistrar : CommandRegistrar
	{
		#region Construction
		/// <summary>
		/// Initializes a new instance of the <see cref="PolicyInjectionCallHandlersCommandRegistrar"/> class.
		/// </summary>
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		public PolicyInjectionCallHandlersCommandRegistrar(IServiceProvider serviceProvider)
			: base(serviceProvider)
		{ }
		#endregion

		#region Public Methods
		/// <summary>
		/// Register the commands.
		/// </summary>
		public override void Register()
		{
			AddDefaultCommands(typeof(CursorCallHandlerNode));
			AddMoveUpDownCommands(typeof(CursorCallHandlerNode));
			AddMultipleChildNodeCommand(Resources.AddCursorCallHandlerCommandText,
					Resources.AddCursorCallHandlerCommandTextLong,
					typeof(CursorCallHandlerNode),
					typeof(CallHandlersCollectionNode));

			AddDefaultCommands(typeof(OneWayCallHandlerNode));
			AddMoveUpDownCommands(typeof(OneWayCallHandlerNode));
			AddMultipleChildNodeCommand(Resources.AddOneWayCallHandlerCommandText,
					Resources.AddOneWayCallHandlerCommandTextLong,
					typeof(OneWayCallHandlerNode),
					typeof(CallHandlersCollectionNode));

			AddDefaultCommands(typeof(SynchronizedCallHandlerNode));
			AddMoveUpDownCommands(typeof(SynchronizedCallHandlerNode));
			AddMultipleChildNodeCommand(Resources.AddSynchronizedCallHandlerCommandText,
					Resources.AddSynchronizedCallHandlerCommandTextLong,
					typeof(SynchronizedCallHandlerNode),
					typeof(CallHandlersCollectionNode));

			AddDefaultCommands(typeof(ThreadSafeCallHandlerNode));
			AddMoveUpDownCommands(typeof(ThreadSafeCallHandlerNode));
			AddMultipleChildNodeCommand(Resources.AddThreadSafeCallHandlerCommandText,
					Resources.AddThreadSafeCallHandlerCommandTextLong,
					typeof(ThreadSafeCallHandlerNode),
					typeof(CallHandlersCollectionNode));

			AddDefaultCommands(typeof(TransactionScopeCallHandlerNode));
			AddMoveUpDownCommands(typeof(TransactionScopeCallHandlerNode));
			AddMultipleChildNodeCommand(Resources.AddTransactionScopeCallHandlerCommandText,
					Resources.AddTransactionScopeCallHandlerCommandTextLong,
					typeof(TransactionScopeCallHandlerNode),
					typeof(CallHandlersCollectionNode));
		}
		#endregion
	}
}